module teapo.storage.attached.dom { export class UpdateStorage { private _parentElement: HTMLElement,
private _byName: { [fullPath: string]: HTMLElement; }, private _document: { createElement(tag: string): HTMLElement; }) { update(file: string, property: string, value: string, callback?: (error: Error) => void): void { var element = this._getExistingElement(file);
element = UpdateStorage.createElement(this._parentElement, file, this._document);
this._byName[file] = element;
UpdateStorage.updateProperty(element, property, value);
this._parentElement.setAttribute('data-edited-utc', Date.now() + ''); remove(file: string, callback?: (error: Error) => void): void { var element = this._getExistingElement(file);
callback(new Error('file does not exist.')); element.parentElement.removeChild(element);
delete this._byName[file];
this._parentElement.setAttribute('data-edited-utc', Date.now() + ''); static createElement(parentElement: HTMLElement, fullPath: string, _document: { createElement(tag: string): HTMLElement; }): HTMLElement { var element = _document.createElement('div'); element.setAttribute('data-path', fullPath); parentElement.appendChild(element);
static updateProperty(element: HTMLElement, property: string, value: string): void { element.setAttribute('data-meta-' + encodeForAttributeName(property), value); private _getExistingElement(fullPath): HTMLElement { var element = this._byName.hasOwnProperty(fullPath) ? this._byName[fullPath] : null;